

module.exports = {
  async get({ req, res, config, api }) {
    res.send("index - get");
  },
  async post({ req, res, config, api, db }) {
    let data = await db.user.find(req.body)
    if (data.length) {
      res.info('用户已被注册！')
    } else {
      let { name, password } = req.body;
      let User = new db.user({ name, password })
      await User.save();
      res.success('ok')
    }
  },
  async del({ req, res, config, api }) {
    res.send("index - del");
  },
  async put({ req, res, config, api }) {
    res.send("index - put");
  },
  doc: {
    post: {
      tags: ['user'],
      name: 'name',
      description: '描述',
      body: {},
      query: {},
      response: {}
    },
    get: {
      tags: ['user'],
      name: 'name',
      description: '描述',
      body: {},
      query: {},
      response: {}
    }
  }
};